<%@page contentType="text/html" %>
<%@page pageEncoding="UTF-8" %>

<%@taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@taglib prefix="a4j" uri="http://richfaces.org/a4j" %>
<%@taglib prefix="rich" uri="http://richfaces.org/rich" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Goodwill - Товары</title>
    <link rel="stylesheet" href="resources/css/main.css"/>
    <link rel="stylesheet" href="resources/css/stylesheet.css"/>
    <script type="text/javascript" src="resources/js/goodwill.js"></script>
    <style type="text/css">
    </style>
</head>
<body>
<f:view>

    <jsp:include page="menu.jsp"/>
    <jsp:include page="orderClientInfo.jsp"/>
    <jsp:include page="orderTopBar.jsp"/>
    <jsp:include page="status.jsp"/>
    <jsp:include page="messages.jsp"/>

    <h:form prependId="false">

        <h:panelGroup styleClass="" layout="block">

            <%-- -------------- Поиск -------------- --%>
            <h:panelGroup styleClass="" layout="block" style="background-color:whitesmoke;padding-left:2px">
                <h:outputLabel value="Поиск по оригинальному номеру запчасти" styleClass="b"/>
                <h:inputText value="#{SessionBean.goodsFilter.oe}" style="margin-left:10px"/>
                <a4j:commandButton value="Поиск" action="#"
                                   style="margin-left:10px"
                                   oncomplete="document.location='ManagerGoodsSearchPage.jsf'">
                    <a4j:actionparam name="goodTypeId" assignTo="#{SessionBean.goodsFilter.goodTypeId}" value="-1"/>
                </a4j:commandButton>
            </h:panelGroup>

            <rich:separator/>

            <%-- -------------- Путь -------------- --%>
            <h:panelGroup styleClass="" layout="block" style="background-color:whitesmoke;padding-left:2px">
                <%-- EXPERIMENTAL --%>
                <a4j:commandLink value="Главная" onclick="document.location='ManagerGoodsPage.jsf'">
                </a4j:commandLink>
                <%--<a4j:commandLink value="Главная" ajaxSingle="true"--%>
                                 <%--oncomplete="document.location='ManagerGoodsPage.jsf'">--%>
                    <%--<a4j:actionparam name="path_Id" assignTo="#{SessionBean.goodsFilter.goodTypeId}" value="-1"/>--%>
                    <%--<a4j:actionparam name="searchOE" assignTo="#{SessionBean.goodsFilter.oe}" value=""/>--%>
                <%--</a4j:commandLink>--%>

                <a4j:repeat value="#{SessionBean.path}" var="p">
                    <a4j:commandLink value="#{p.name}" ajaxSingle="true"
                                     oncomplete="document.location='ManagerGoodsSearchPage.jsf'">
                        <a4j:actionparam name="path_Id" assignTo="#{SessionBean.goodsFilter.goodTypeId}"
                                         value="#{p.id}"/>
                        <a4j:actionparam name="searchOE" assignTo="#{SessionBean.goodsFilter.oe}" value=""/>
                    </a4j:commandLink>
                </a4j:repeat>
            </h:panelGroup>
        </h:panelGroup>

        <%-- -------------- Список груп товаров -------------- --%>
        <rich:dataGrid value="#{ClientGoodsBean.goodTypes}" var="goodType" columns="3" columnClasses="top,top,top" style="border:0" border="0">
            <rich:panel>
                <f:facet name="header">
                    <h:outputText value="#{goodType.name}"/>
                </f:facet>
                <a4j:repeat value="#{goodType.children}" var="child">
                    <a4j:commandLink value="#{child.name}" ajaxSingle="true"
                                     oncomplete="document.location='ManagerGoodsSearchPage.jsf'">
                        <a4j:actionparam name="goodType_Id" assignTo="#{SessionBean.goodsFilter.goodTypeId}"
                                         value="#{child.id}"/>
                        <a4j:actionparam name="searchOE" assignTo="#{SessionBean.goodsFilter.oe}" value=""/>
                    </a4j:commandLink><br>
                </a4j:repeat>
            </rich:panel>
        </rich:dataGrid>

    </h:form>    
</f:view>
</body>
</html>
